<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>v-bind</title>
    <style>
        .test {
            color: red;
        }
        
        .vueTest {
            border: 1px solid red;
        }
    </style>
</head>

<body>
    <h1>直接操作某一个值/dom元素</h1>
    <div id="app">

        <div class="test" :class="action ? 'vueTest':'' ">测试类表达式</div>

        <!-- 简写三元表达式 -->
        <div class="test" :class="{vueTest:action} ">测试类表达式</div>
        <button @click="toggleClass">切换类</button>

        <!-- 完整写法 -->
        <img v-bind:src="imgSrc" alt="草莓">
        <br>
        <!-- 简写 -->
        <img :src="imgSrc" alt="草莓" :title="title">


    </div>
    <!-- 开发环境版本，包含了有帮助的命令行警告 -->
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
    <script>
        var app = new Vue({
            el: '#app',
            data: {
                imgSrc: 'https://dss0.bdstatic.com/70cFuHSh_Q1YnxGkpoWK1HF6hhy/it/u=1906469856,4113625838&fm=26&gp=0.jpg',
                title: "vue测试",
                action: true
            },
            methods: {
                toggleClass: function() {
                    this.imgSrc = 'https://dss1.bdstatic.com/70cFvXSh_Q1YnxGkpoWK1HF6hhy/it/u=3374235652,2809672903&fm=26&gp=0.jpg'
                    this.action = !this.action;
                    console.log(this.action);
                }
            }
        })
    </script>
</body>

</html>